<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>BOM和DOM</title>
</head>
<body>

<input type="button" value="警告框"
       onclick="useAlert()">
<input type="button" value="确认框"
       onclick="useConfirm()">
<input type="button" value="输入框"
       onclick="usePrompt()">

<input type="button" value="打开新窗口"
       onclick="useOpen()">

<input type="button" value="关闭"
       onclick="useClose()">

<script>

    // BOM
    // 浏览器对象模型(Browser Object Model)
    // 可以操作浏览器相关的功能
    // DOM
    // 文档对象模型(Document Object Model)
    // 可以访问和操作html页面的标签

    function useAlert() {
        alert("测试警告框");
    }

    function useConfirm() {
        var result = confirm("啊啊啊啊");

        if (result) {
            console.log("确认");
        } else {
            console.log("取消");
            useConfirm();
        }
    }

    function usePrompt() {

        var s = prompt("请输入密码:","例如:123123123");

        console.log(s);

        if (s == null) {
            console.log("取消");
        } else {
            console.log("输入的内容是:" + s);
        }

    }

    function useOpen() {
        open("http://www.baidu.com","newWindow",
            "width=400,height=300");
    }

    useOpen();

    function useClose() {
        close();
    }



</script>
</body>
</html>